<div class="form">

<p>&nbsp;</p>

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'recipient-form',
	'enableAjaxValidation'=>true,
)); ?>

<?php
$this->widget('zii.widgets.jui.CJuiButton',
	array(
		'name'=>'button',
                'caption'=>'new user',
		'value'=>'asd',
		'onclick'=>'js:function(){
                    $("#tbl_organisation_new").val("1");
                    $("#sub_tbl_organisation_org_childid").val("");
                    $("#rec_save_button").attr("value","Create");
                    jQuery.ajax({"type":"POST","url":"'.Yii::app()->createUrl('//kommunikation/dynamickommunikation').'","data":{"org_id":0},"success":function(html){jQuery("#Recipient_kom_id").html(html)}});
                }',
		)
);
?>

<?php echo CHtml::ajaxButton($model->isNewRecord ? 'Create' : 'Update',
        CHtml::normalizeUrl(array('//organisation/subviewedit')),
        array(
            'type'=>'POST',
            'success'=>'function(responseText,statusText) {
                            $.fn.yiiGridView.update(\'recipient_table\');
                        }',
        ),
        array('class'=>'ui-button ui-widget ui-state-default ui-corner-all','id'=>'rec_save_button'));
?>



    <fieldset class="box">
        <legend>Recipient</legend>
	<?php echo $form->errorSummary($model); ?>

        <table>
            <tr class="row">
                <td width="100px">
                    <?php echo $form->labelEx($model,'tbl_organisation_org_id'); ?>
                </td>
                <td width="150px">
                    <?php

                    $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                       //'model'=>$model,
                       'name'=>'sub_tbl_organisation_org_childid',
                       'value'=>CHtml::encode(Organisation::model()->findByPK($model->tbl_organisation_org_childid)->nachname),
                       'source' => $this->createUrl('Organisation/autocompleteOrganisation'),
                       'options' => array(
                            'minLength'=>'2',
                            'select'=>"js:function(event,ui){
                                $('#".CHtml::activeId($model,'tbl_organisation_org_childid')."').val(ui.item.id);
                                jQuery.ajax({'type':'POST','url':'".Yii::app()->createUrl('//kommunikation/dynamickommunikation')."','data':{'org_id':ui.item.id},'success':function(html){jQuery('#OrganisationHasTblOrganisation_kom_id').html(html)}});
                            }",
                       ),
                    ));

                    ?>
                    <?php echo $form->hiddenField($model,'tbl_organisation_org_childid'); ?>
                    <?php echo $form->error($model,'tbl_organisation_org_childid'); ?>

                    <?php echo CHtml::hiddenField('tbl_organisation_new',1); ?>
                </td>
                <td>
                    <?php echo CHtml::activedropDownList($model,'kom_id',array('0'=>'empty')); ?>
                    <?php echo $form->error($model,'kom_id'); ?>
                </td>
           </tr>
        </table>

		<?php echo $form->hiddenField($model,'tbl_organisation_org_id'); ?>
		<?php echo $form->error($model,'tbl_organisation_org_id'); ?>

   </fieldset>
    <p class="note">Fields with <span class="required">*</span> are required.</p>

<?php $this->endWidget(); ?>

</div><!-- form -->

<?php
$this->widget('ext.ajaxform.JAjaxForm',array(
    'formId'=>'recipient-form',
    'options'=>array(
        'dataType'=>'json',
    ),
));
?>
